# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ncspot
pkgver=0.10.0
pkgrel=0
pkgdesc="Cross-platform ncurses Spotify client inspired by ncmpc and the likes"
url="https://github.com/hrkfdn/ncspot"
# ppc64le: fails to build ring crate
# others: limited by rust/cargo
arch="aarch64 armhf armv7 x86 x86_64"
license="BSD-2-Clause"
makedepends="
	cargo
	dbus-dev
	libxcb-dev
	ncurses-dev
	openssl-dev
	pulseaudio-dev
	python3
	"
source="https://github.com/hrkfdn/ncspot/archive/v$pkgver/ncspot-$pkgver.tar.gz"
options="!check"  # there's only one unit test (in v0.8.1)

# Optimize binary for size (18 MiB -> 8.2 MiB in v0.8.1).
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
export CARGO_PROFILE_RELEASE_PANIC="abort"

_cargo_opts='--frozen --features cover,share_selection'

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build $_cargo_opts --release
}

check() {
	cargo test $_cargo_opts
}

package() {
	cargo install $_cargo_opts --offline --path . --root="$pkgdir/usr"
	rm "$pkgdir"/usr/.crates*
}

sha512sums="
7eb190264f119a5d6ce1809b3b93910c827476c138867892ae06aee90f2c846cd172a1faea39307b87d20c2632eac1bc93682a7588980d2fdf4a82a8edded78f  ncspot-0.10.0.tar.gz
"
